import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: "/home/dashboard"  //首页需要设置路由重定向
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  {//仪表盘的路由和子路由
    path: '/home',
    name: "home",
    component: layout,
    children: [
      { path: "dashboard", name: "dashboard", component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue') },
      { path: "data", name: "dashboarddata", component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/data.vue') }
    ]
  },
  {
    //设备的路由和子路由
    path: '/device',
    name: '/device',
    component: layout,
    children:[
      {path: "gateway",name:"gateway", component: () => import(/* webpackChunkName: "dashboard" */ '../views/device/gateway.vue')},
      {path: "group",name:"group", component: () => import(/* webpackChunkName: "dashboard" */ '../views/device/group.vue')},
      {path: "sensor",name:"sensor", component: () => import(/* webpackChunkName: "dashboard" */ '../views/device/sensor.vue')}
    ]
  },


  {
    path: '*',
    name: 'page404',
    component: () => import(/* webpackChunkName: "page404" */ '../views/page404/index.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
